<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    
</head>
<body>


    <h6>JavaScript 数组排序</h6>

    <button onclick="myFunction()">升</button>
    
    <button onclick="myFunction1()">降</button>
    
    
    <p id="demo"></p>
    
    <script>
    var points = [40, 100, 1, 5, 25, 10];
    document.getElementById("demo").innerHTML = points;  
    
    function myFunction() {
      points.sort(function(a, b){return a - b});
      document.getElementById("demo").innerHTML = points;
    }
    function myFunction1() {
      points.sort(function(a, b){return b - a});
       document.getElementById("demo").innerHTML = points;
}
    </script>
    
    








</body>
</html>

